package com.yztctech.a24_02_normalbroadcast_dynamicregist;

import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;

/**
 * Created by bodhixu on 2016/9/23.
 * 动态广播用于下载功能,还能用于什么
 *
 */
public class DownloadTask extends AsyncTask{

    private Context context;

    public DownloadTask(Context context) {
        this.context = context;
    }

    @Override
    protected Object doInBackground(Object[] objects) {
        //模拟网络下载
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Object o) {
        super.onPostExecute(o);

        //发送广播
        Intent intent = new Intent(MyConstants.ACTION_DOWNLOAD);
        intent.putExtra(MyConstants.KEY_RESULT, "Success");
        context.sendBroadcast(intent);
    }
}
